#include"utils.h"

#define TITLE_SIZE 45
#define FILM_SIZE 5

struct film{
    char title[TITLE_SIZE];
    int rating;
};

int main() {
    struct film movies[FILM_SIZE];
    int i = 0;
    int j;

    puts("Enter first movie title:");
    while(i < FILM_SIZE && s_gets(movies[i].title, TITLE_SIZE) != NULL &&
            movies[i].title[0] != '\0') {
                puts("Enter your rating <0-10>:");
                scanf("%d", &movies[i++].rating);
                while(getchar() != '\n') {
                    continue;
                }
                puts("Enter next movie title (empty line to stop):");
            }
    if (i == 0) {
        printf("No data entered. ");
    } else{
        printf("Here is the movie list:\n");
    }

    for (j = 0; j < i; j++) {
        printf("Movie: %s Rating: %d\n", movies[j].title, movies[j].rating);
    }
    printf("Bye\n");
    return 0;
}